<?php 
$_thumbnail = 'img/blueprint.png';
$_action = 'add';
$_type_id = tos_http_get('type_id');

if($this->has_data('thumbnail')) {
    $_thumbnail = $this->get_data('thumbnail');
}
if ($this->has_data('action')) {
    $_action = $this->get_data('action');
}
if ($this->has_data('type_id')) {
    $_type_id = $this->get_data('type_id');
}
$prev_node_mapping = $this->get_data('prev_node_mapping');
$node_keywords = $this->get_data('node_keywords');
?>
<div id="ne_w">
<div id="pne"></div>
<div id="ne">
<h1 class="caption"><?php $this->write('page_caption')?></h1>
<div class="box">
<div class="thumbnail">
    <img src="<?php echo tos_cdn_url($_thumbnail);?>" />
</div>
<div>
    <b>Caption:</b><br />
    <div><?php $this->write('caption');?></div>
</div>
<div>
    <b>Url segment:</b><br />
    <div><?php $this->write('url_segment');?></div>
</div>
<div>
    <b>Description:</b><br />
    <div><?php $this->write('description')?></div>
</div>
<?php $this->display_box();?>
<div class="clear"></div>
</div>
</div>
</div>

<script type="text/javascript">
var knm;
function init_knm () {
    if (undefined == knm) {
        knm = new z.knm(z.s('pne'), document.forms['node_form']);
        
        <?php if ('add' == tos_http_get('a')) : ?>
        knm.add_require('caption');
        <?php endif; ?>
        
        <?php if (isset($prev_node_mapping)): ?>
            <?php foreach ($prev_node_mapping as $nm):?>
                <?php 
                    $_keyword = isset($node_keywords[$nm['keyword_id']])? 
                        $node_keywords[$nm['keyword_id']]['keyword'] : '';
                ?>
                knm.add_kn(
                    '<?php echo $_keyword;?>',
                    <?php echo json_encode($nm);?>
                        );
            <?php endforeach;?>
        <?php endif;?>
        <?php if (isset($node_keywords)): ?>
            <?php foreach ($node_keywords as $node_keyword): ?>
                knm.add_kn('<?php echo $node_keyword['keyword']; ?>');
            <?php endforeach;?>
        <?php endif;?>
                knm.add_kn();
    }
}
init_knm();
</script>